<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en"><head>
    <meta charset="utf-8">
    <title>教师管理登陆</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <style type="text/css">
      body{
        padding-top: 40px;
        padding-bottom: 40px;
        
      }

      .form-signin {
        max-width: 300px;
        padding: 19px 29px 29px;
        margin: 50 auto 20px;
        background-color: #fff;
        border: 1px solid #e5e5e5;
        -webkit-border-radius: 5px;
           -moz-border-radius: 5px;
                border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
      }
      .form-signin .form-signin-heading,
      .form-signin .checkbox {
        margin-bottom: 10px;
      }
      .form-signin input[type="text"],
      .form-signin input[type="password"] {
        font-size: 16px;
        height: auto;
        margin-bottom: 15px;
        padding: 7px 9px;
      }

    </style>
    <link rel="stylesheet" type="text/css" href="<%=path %>/res/common/bootstrap-3.3.7-dist/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path %>/res/common/bootstrap-3.3.7-dist/css/bootstrap-theme.css"/>
 	
 	<script src="<%=path %>/res/common/js/jquery-1.11.1.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=path %>/res/common/js/jquery.validate.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=path %>/res/common/js/additional-methods.js" type="text/javascript" charset="utf-8"></script>
		
  	<script type="text/javascript">
			$(function() {
				// 生成一个简单的验证码
				function randomNumber(min, max) {
					return Math.floor(Math.random() * (max - min + 1) + min);
				};
				function generateCaptcha() {
					$('#captchaOperation').html([randomNumber(1, 50), '+', randomNumber(1, 50), '='].join(' '));
				};
				generateCaptcha();
				function getValue() {
					var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]);
					return value = sum;
				}
				document.getElementById("yz1").value=getValue(); 
				//让当前表单调用validate方法，实现表单验证功能
				$("#myform").validate({
					//debug:true,	//调试模式，即使验证成功也不会跳转到目标页面
					onkeyup: null,
					rules: { //配置验证规则，key就是被验证的dom对象，value就是调用验证的方法(也是json格式)
						user: {
							required: true
						},
						pass: {
							required: true
						},
						yz2:{
						required: true,
						number:true,
						equalTo: '#yz1' //表示和id="captcha"的值相同
						}
					},
					messages: {
						user: {
							required: "请输入用户名"
						},
						pass: {
							required: "请输入密码"
						},
						yz2:{
							required: "请输入验证码",
							number:"只能输入数字",
							equalTo:"验证码错误"
						}
					}
				});
			});
		</script>
  </head>

  <body style="background: url(<%=path %>/res/common/imgs/loginbeijing1.jpg);">

    <div class="container">

      <form id="myform" action="teacherIndex.do" method="post" class="form-signin">
        <h2 class="form-signin-heading">教师管理登录</h2>
        <div style="color: red;">
        ${usermsg}</div>
        <input class="input-block-level" id="user" name="user" type="text" placeholder="用户名">
       	<div style="color: red;">
        ${pwdmsg}</div>
        <input class="input-block-level" id="pass" name="pass" type="password" placeholder="密码">
        <h5>请将如下计算结果填入文本框内：</h5>
		<div class="form-group form-horizontal">
		<label class="col-lg-5 control-label " id="captchaOperation"></label>
		<div class="col-lg-7">
		<input type="text" id="yz1" name="yz1" style="display:none"/>
		<input type="text" class="form-control " id="yz2"  name="yz2" />
		</div>
		</div><br /><br /> <br /> 
        <button class="btn btn-large btn-primary" type="submit">确定</button>
		<a href="teacherRegister.do">注册新用户</a>
      </form>
    </div> <!-- /container -->

</body></html>